package collectionTest;

import java.awt.List;
import java.util.ArrayList;

interface IntegerStack{
public Integer push(Integer item);//如item为null，则不入栈直接返回null。如栈满，也返回null.
public Integer pop();//出栈，如为空，则返回null.
public Integer peek();//获得栈顶元素，如为空，则返回null.
public boolean empty();//如为空返回true
public int size();//返回栈中元素数量
}

class ArrayListIntegerStack implements IntegerStack{
	//private static final IntegerStack list = null;
	ArrayList<Integer> list;
	
	
	public ArrayListIntegerStack(){
		list=new ArrayList<Integer>();
	}



	@Override
	public Integer push(Integer item) {
		if(item==null)// TODO Auto-generated method stub
		return null;
		list.add(item);
		return item;
	}




	@Override
	public Integer pop() {
		if(list.isEmpty())// TODO Auto-generated method stub
		return null;
		return list.remove(list.size()-1);
	}





	@Override
	public Integer peek() {
		if(list.isEmpty())// TODO Auto-generated method stub
		return null;
		return list.get(list.size()-1);
	}






	@Override
	public boolean empty() {
		return list.size()==0?true:false;
	}







	@Override
	public int size() {
		return list.size();
	}






	@Override
	public String toString() {
		return "Main [getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString()
				+ "]";
	}

	
	public class Main {
	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub

	}

}